module.exports = function($scope, $modal, $state, $stateParams,$resource){

    //查询已发消息列表
    $scope.search = function (pageNo){
        var para = { 
            'name': $scope.name,
            'pageNo': pageNo || $scope.currentPage,
            'pageSize': $scope.itemsPerPage
            
        }
        $resource('/api/as/tc/ticketStyle/findList', {}, {}).save(para, function(res){
            if(res.errcode === 0){
                $scope.list = res.data.results;
                $scope.totalItems = res.data.totalRecord;

                $scope.currentPage = pageNo;
            }else{
                toaster.error({title: '', body: res.errmsg});
            }
        });
    }

        //查询已发消息列表
        $scope.del = function (info){
            var para = { 
                'id': info.id
            }
            $resource('/api/as/tc/ticketStyle/del', {}, {}).save(para, function(res){
                if(res.errcode == 0){
                    toaster.success({title: '', body: '删除成功'});
                    init();
                }else{
                    toaster.error({title: '', body: res.errmsg});
                }
            });
        }

    init();
    //初始化列表
    function init(){
        $scope.currentPage = 1;		//当前页码
        $scope.itemsPerPage = 10;	//每页显示几条
        $scope.search(1);
    }

     //查看
     $scope.saveInfo = function(info) {
        var modalInstance = $modal.open({
            template: require('../views/ticketStyleInfo.html'),
            controller: 'ticketStyleInfo',
            size: 'lg',
            resolve: {
                item : function () {
                    return info;
                },
                flag : function () {
                    return info == 1;
                }
            }
        });
        //关闭模态框刷新页面
        modalInstance.result.then(function() {
            init();
        });
    }

};